package com.example.Sao.Tools;

import android.content.Context;
import android.content.IntentFilter;

import com.example.Sao.MyReceiver.ServiceReceiver;

/**
 * @ProjectName: scan
 * @Package: com.example.MyApplication.Tools
 * @ClassName: Serceiveutil
 * @Description: java类作用描述
 * @Author: 作者名
 * @CreateDate: 2020/4/17 12:06
 * @UpdateUser: 更新者：
 * @UpdateDate: 2020/4/17 12:06
 * @UpdateRemark: 更新说明：
 * @Version: 1.0
 */
public class BroadcastUtil {
    private static ServiceReceiver musbReceiver = null;

    public static void  Register(Context context, ServiceReceiver usbReceiver){
        musbReceiver = usbReceiver;
        IntentFilter filter = new IntentFilter();
        filter.addAction("android.hardware.usb.action.USB_STATE");
        context.registerReceiver(musbReceiver,filter);
    }

    public static void UnRegister(Context context){
        if (musbReceiver!=null){
            context.unregisterReceiver(musbReceiver);
        }
    }
}
